package com.yfkj.support.mq.rabbit;


import com.yfkj.support.constans.MessageQueuePipeline;
import com.yfkj.support.mq.SendMqService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;

/**
 *  RabbitMq发送类
 */
@Service
@ConditionalOnProperty(name = "yfkj.mq.pipeline", havingValue = MessageQueuePipeline.RABBIT_MQ)
public class RabbitMqSendServiceImpl implements SendMqService {

    @Autowired
    private RabbitTemplate rabbitTemplate;


    @Value("${yfkj.rabbitmq.exchange.name}")
    private String exchangeName;


    @Override
    public void send(String topic, String jsonValue, String tagId) {
        rabbitTemplate.convertAndSend(exchangeName, topic, jsonValue);
    }

    @Override
    public void send(String topic, String jsonValue) {
        send(topic, jsonValue, null);
    }
}
